﻿#region COPYRIGHT© 2009-2013 Phillip Clark. All rights reserved.

// For licensing information see License.txt (MIT style licensing).

#endregion

using FlitBit.Parse;

namespace FlitBit.Json
{
	public sealed class JsonParser
	{
		JsonTokenizer _tokenizer;

		public JsonParser()
			: this(false)
		{}

		public JsonParser(bool ignoreWhitespace)
		{
			_tokenizer = new JsonTokenizer(ignoreWhitespace);
		}

		public JsonValue Convert(string json)
		{
			var state = new TokenizerState<JsonTokenKind>(_tokenizer.Tokenize(json));
			return JsonValue.ExpectValue(state);
		}
	}
}